<?php
	include_once '../../config.php';

/**
 * return array(array('actionName' => 'string',
  	 					'productID'=> 'string',
  	 					'origion_price' => 'double',
  	 					'status'=> 'string(open,close)',
  	 					'timeleft' => 'long',
  	 					'aution_price'=> 'double',
  	 					'current_user_bid'=> 'userID: string',
  	 					'price_per_bid' => 'int'))
 */
$error = false;
$connection = mysql_connect ($host, $username, $password) or die ( $connect_error . mysql_error () );

$productList = ! empty ( $_POST ['data'] ) ? $_POST ['data'] : "";
/*
$productList = explode ( ",", $productList );
foreach ( $productList as &$product ) {
	$product = $product;
}
*/


mysql_select_db ( $db, $connection ) or die ( $connect_error . mysql_error () );
$delete_result = @mysql_query ( "delete from Product WHERE productID IN (" . $productList . " )", $connection );

if (!$delete_result) {
	$error =true;
die(mysql_error ());
}

if (!$delete_result) {
	$error =true;
die(mysql_error ());
}

$result = @mysql_query ( "select * from Product", $connection );
if (!$result) $error = true;
$arr = array ();
while ( $row = @mysql_fetch_assoc ( $result ) ) {
	

	
	
	$arr = array_merge ( $arr, array (
			array (
					'productID' => $row['productID'],
					'name' => $row['name'],
					'manufacturer_name' => $row ['manufacturer_name'] ,	
					'supplier_name' => $row ['supplier_name'] ,
					'category_name' => $row ['category_name'],
					'price' => $row ['price'],
					'image' => $row['image'],

					'error' =>$error
			) 
	) );
}
mysql_close($connection);
die ( json_encode ( $arr ) );
	
